<?php

class Form_Torrent extends Zend_Form
{

    public function init()
    {
    	$this->setName('Torrent');
    	$this->setMethod('post');
    	
    	$torrent = new Zend_Form_Element_File('torrent');
    	$torrent->setLabel('Torrent file:')
    			->setRequired()
    			->addValidator('Extension',false,'torrent');
    	
        $name = new Zend_Form_Element_Text('name');
        $name->setLabel('Torrent Name')
        		->setRequired()
        		->addValidator('StringLength', false, array('min' => 5,'max' => 255))
        		->addFilter('StringTrim')
        		->addFilter('StripTags');
        		
        $section = new Zend_Form_Element_Select('section_id');
        $section->setLabel('Section:')
        		->setAttrib('id', 'section-select');
        
		$section->addMultiOption('0','Choose');
        $section->addMultiOptions(Model_Section::getList());
        
        $category = new Zend_Form_Element_Select('category_id');
        $category->setLabel('Category:')
        		->setAttrib('id', 'category-select');
        		
		$category->addMultiOption('0', 'First choose section');
		
		$description = new Zend_Form_Element_Textarea('description');
		$description->setLabel('Torrent description:')
				->setAttribs(array(
        			'rows' => 5,
        			'cols' => 30,
        			'id'   => 'torrent-editor'
        		))
        		->addFilter('StringTrim')
        		->addFilter('StripTags');
        		
        $submit = new Zend_Form_Element_Submit('addtorrent');
        $submit->setLabel('Add torrent');
        
        $this->addElements(array($torrent,$name,$section,$category,$description,$submit));
    }


}

